<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/component/pear/css/pear.css"/>
    <style>
        label.required:after { /* 给红色的必填项打红色星号（文字后）如果打前面用before*/
            content: ' *';
            color: red;
        }

        .layui-form-label {
            height: 50px;
            line-height: 45px;
            padding: 0px;
        }

        .layui-form .layui-input-inline {
            margin-left: 30px;
            width: 290px;
        }

        .main-container .layui-form-item {
            margin: 20px 0px !important;
        }

        .layui-input {
            height: 50px;
        }

        .layui-disabled, .layui-disabled:hover {
            color: #0d0c0c !important;
        }
    </style>
</head>
<body>
<div class="main-container"
     style="display: flex;flex-direction: column;height: calc(100vh - 50px);">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="font-size: 16px;">
        <form class="layui-form" action="" onsubmit="return false">
            <div class="layui-form-item">
                <label class="layui-form-label required">图纸名称</label>
                <div class="layui-input-block">
                    <input type="text" name="sonFileName" required lay-verify="required"
                           lay-reqtext="请输入图纸名称" id="fileNameInput" disabled
                           placeholder="请输入图纸名称" th:value="${archivesSubname.sonFileName}"
                           autocomplete="off" class="layui-input layui-disabled">
                </div>
            </div>
            <div class="layui-form-item required">
                <label class="layui-form-label">图纸总数</label>
                <div class="layui-input-block">
                    <input type="number" name="drawingCount" placeholder="请输入图纸总数" id="drawingCount" required th:value="${archivesSubname.drawingCount}"
                           lay-verify="required" lay-reqtext="请输入图纸总数" autocomplete="off" disabled class="layui-input layui-disabled">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="profile" th:value="${archivesSubname.profile}"
                           autocomplete="off" disabled class="layui-input layui-disabled">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">创建时间</label>
                <div class="layui-input-block">
                    <input type="text" name="createTime" th:value="${archivesSubname.createTime}"
                           autocomplete="off" disabled class="layui-input layui-disabled">
                </div>
            </div>
            <div class="layui-form-item" style="display: flex;flex-direction: column;align-items: center;">
                <div style="width: 97%;height: 1px;background: #E9E9E9;"></div>
            </div>
        </form>
    </div>
</div>
<script src="/component/layui/layui.js"></script>
<script src="/component/pear/pear.js"></script>
<script th:inline="javascript">
    var archivesId = [[${archivesId}]];
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        // 提交事件
        form.on('submit(archivesSubnameSave)', function (data) {
            let loading = layer.load();
            data.field.archivesId = archivesId;
            $.ajax({
                url: '/archives/subname/update/save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: "application/json;charset=utf-8",
                type: 'post',
                success: function (result) {
                    layer.close(loading);
                    if (result.code === 200) {
                        layer.msg(result.message, {icon: 1, time: 1800}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        });
                    } else {
                        layer.msg(result.message, {icon: 2, time: 1800});
                    }
                }
            })
            return false;
        });
    });
</script>
</body>
</html>